{extend name="personcentor/information"}


{block name="main"}

			<div class="col-main">
				<div class="main-wrap">

					<div class="am-cf am-padding">
						<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">修改密码</strong> / <small>Password</small></div>
					</div>
					<hr/>
					<br/>
					<br/>
					<br/>

					<form class="am-form am-form-horizontal" method="post" name="myform" action="{:url('index/personcenter/updatepass')}" onsubmit="return checkForm()" >
						<div class="am-form-group">
							<label  class="am-form-label" name="pin">原密码</label>
							<div class="am-form-content">
								<input type="password" id="user-old-password" placeholder="请输入原登录密码">
								<span class="content" ></span>
							</div>

						</div>
						<div class="am-form-group">
							<label for="user-new-password" class="am-form-label" >新密码</label>
							<div class="am-form-content">
								<input type="password" id="user-new-password" placeholder="由数字、字母组合,6-12位" name="newpass">
								<span id="newcontent" ></span>
							</div>
						</div>
						<div class="am-form-group">
							<label for="user-confirm-password" class="am-form-label" >确认密码</label>
							<div class="am-form-content">
								<input type="password" id="user-confirm-password" placeholder="请再次输入上面的密码" name="tbc" >
								<span id="renewcontent" ></span>
							</div>
						</div>
						<div class="info-btn">
							<button class="am-btn am-btn-danger okbtn" disabled>保存修改</button>
						</div>

					</form>

				</div>

			</div>


         <script>
                 //验证原密码与输入的密码是否匹配
                   $('#user-old-password').blur(function(){

                        var oldpa =  $('#user-old-password').val();

                        $.ajax({
                           type : 'post',
							url : '/personcenter/passcom',
							data : {"pass":oldpa},
							success:function(data){
                               if(data){
                                   console.log(data);
                                  $('.content').html('√原密码正确').css('color','#0a0');

                                   $('.okbtn').removeAttr("disabled");

							   }else{
                                   $('.content').html('×与原密码不匹配').css('color','#f00');
                                   $('.okbtn').attr("disabled","true");
							   }
							},
							error : function(){
							    alert('ajax请求失败');
							}
						})
				   });

			    //验证新密码与确认新密码

                 //表单验证函数
                 function checkForm () {
                     //验证密码
                     var pwd = document.myform.newpass.value;
                     console.log(pwd);
                     var pt = document.getElementById('newcontent');
                     console.log(pt);
                     if (pwd.length<6 || pwd.length>12) {
                         pt.style.color = '#f00';
                         pt.innerHTML = '× 密码不合法';
                         return false;
                     }else{
                         pt.style.color = '#0a0';
                         pt.innerHTML = '√ 通过';
                     }

                     //重复密码判断
                     var repwd = document.myform.tbc.value;
                     var rpt = document.getElementById('renewcontent');
                     if (repwd !== pwd) {
                         rpt.style.color = '#f00';
                         rpt.innerHTML = '× 两次输入不一致';
                         return false;
                     }else{
                         rpt.style.color = '#0a0';
                         rpt.innerHTML = '√ 通过';
                     }

                     return true;
                 }




		 </script>


{/block}